﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using kwzx.Data;

namespace kwzx
{
    public partial class frmLogin : Form
    {
        public frmLogin()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text;
            string pwd = txtPwd.Text;
            using (HXYKTEntities1 db = new HXYKTEntities1())
            {
               var modle= db.T_USER.Where(a => a.XM == userName).Where(b => b.MM == pwd).ToArray();
               if (modle.Length == 1)
               {
                   frmMain frm = new frmMain();
                   frm.Show();
                   this.Hide();
                   kwzx.Utils.CurrentUser.userName = modle[0].XM;
                   kwzx.Utils.CurrentUser.xm = modle[0].ZSXM;  //真实姓名
                   kwzx.Utils.CurrentUser.bm = (int)modle[0].DEPT_id;  //部门id
                   Utils.CurrentUser.userid = modle[0].user_id;
               }
               else
               {
                   labMsg.Text = "用户名密码错误";
               }
            }
        }

        private void btnCancle_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
